<%@page import="java.util.ArrayList"%>
<%@page import="user.User" contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="sidebar.css" media="screen" />
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>Edit Profile Page</title>
<%User userInfo=null;
        userInfo = (User) session.getAttribute("userInfo");




      //  int privMode=1;
        ArrayList friends=null;
        String username=null,name=null,surname=null,date=null,welcomeText=null;
        String []interests=null;

     //   if (request.getParameter("username").equals(session.getAttribute("username"))) {//re-visit own profile
            out.print("Welcome "+session.getAttribute("username")+"");
               userInfo = (User) session.getAttribute("userInfo");
          //      privMode=1;
                //out.println("id " + session.getAttribute("id") + " </br>");
                name=session.getAttribute("name").toString();
                surname=session.getAttribute("surname").toString();
                interests=session.getAttribute("interests").toString().split(",");
               username=session.getAttribute("username").toString();
        //        welcomeText=session.getAttribute("welcomeText").toString();
                date=session.getAttribute("dateOfBirth").toString();

                userInfo.loadFriendList();
                friends=(ArrayList)session.getAttribute("friends");
               friends=userInfo.getFriendUsernames();


           //    }

        %>
    </head>
    <body>
        <div id ="footbar">
            <div id="RightBar">
            	<br>
                <a href="endSession.jsp">
                        <b>
                <input type="image" src="imadge/on-off.jpg" name="image" background-color="#C0C0C0" width="35" height="35" >
                    </b>
                </a>
            </div>
        </div>
 <div id="rightbar" class="sidebox">
    
     <table id="right">
           <tr> <td>
        <hr>
             <ul>

   <%
 //if(userInfo.pendingFriendRequestsTo.length()>0)
                    //  {out.print(userInfo.pendingFriendRequestsTo.length()+" users want to be your friends");
                     // for(int i=0;i<userInfo.pendingFriendRequestsTo.length();i++)
                       //    out.print("<a href=\"acceptFriend.jsp?username="+userInfo.pendingFriendRequestsTo.get(i)+"Accept</a> "
                         //          +userInfo.pendingFriendRequestsTo.get(i));

               //     }
                  if(friends!=null)
                      out.println("Your Friends are "+friends.size()+"</br> ");



                                for(int i=0;i<friends.size();i++){
%>

<li><b>

                    <%out.println("<a href=profile.jsp?username=" + friends.get(i) + ">" + friends.get(i) + "</a></br>");
               }
               //   if(userInfo.pendingRequestsFromUser().length()>1)
                 //         {for(int i=0;i<userInfo.pendingRequestsFromUser().length();i++)
                   //   out.print("<a href=profile.jsp?username="+userInfo.pendingRequestsFromUser().get(i)+">"+"</a>");
                     //              out.print("These users are not yet sure they want to be your friends");}
               %>

    </b></li>

		<%

               String[] suggestions = userInfo.SuggestFriends();
               if(suggestions!=null)
               if(suggestions.length>=1)
               %><li><% out.print("You should be friends with</br>");
               %></li>><%
                for (int i = 0; i < suggestions.length; i++) {
                    %>

<li><b>
               <%out.print("<a href=profile.jsp?username=" + suggestions[i] + ">" + suggestions[i] + "</a></br>");
                }


            %>
            <a href="manageFriends.jsp">Manage Your Friends</a>
         </b></li>
        </ul>
            <hr>
                comon-popular </br>
                interests list
            <hr>
                </td>
           </tr>
        </table>





</div>
     <div id ="headbar">
            <h1>Abandonware <br/> Place</h1>
            <div id ="searchbar">
            <form action="search.jsp">
   <input type="text" placeholder="search for usernames"/>
   <a href="search.jsp"> Advanced Search</a>
     </form></div>
	</div>
         
        <div id="leftbar" class="sidebox">
        <table style="width:5%;">
           <tr> <td>
                   <a href="profile.jsp"/>
        <hr>
                       <%

                out.print("profile pic</a>");
                   out.println("</br>your personal info</br></br>");


                if(name!=null)
                    out.println("NAME </br>"+name);

                if(surname!=null)
                    out.println(surname+"</br></br>");
               // if(interests!=null)
                 //   out.println(interests);
                if(username!=null)
                    out.println("USERNAME</br>"+username+"</br></br>");
              // if(welcomeText!=null)
                //   out.println(welcomeText);
                if(date!=null)
                    out.println(date);


              %>

      <!--               <b><input type="image" src="imadge/Pixel_Character_6__Yoshi_by_meowmixkitty1.jpg" name="image" width="55" height="55" >
                </b>
          -->
    
             <a href="editProfile.jsp">
                <b>Edit</b>
            </a>

        <hr />
        <% ArrayList temp=userInfo.getUnreadPms();
                if(!temp.isEmpty())
                {    out.println("<a href=readPms.jsp> You have "+temp.size()+"UnreadPms </a>");%>
            <a href="readPms.jsp">
                <b><input type="image" src="imadge/pms.jpg" name="pms" background-color="#C0C0C0" width="35" height="35" >
               </b>
            </a>
            <hr />
        <%}
%>            <a href="newPm.jsp">Sent A new Pm</a>

            Interests
			<ul>

		<%for(int i=0;i<interests.length;i++)
                    {%>
                <li><%out.print(interests[i]);%>
                        </li>    <%}%>

			</ul>
            <hr />
                </td>


                   </tr>
        </table>

        </div>

                        <div id"mainContainer">
                        <%
                        out.print(userInfo.getSuggestions().toString());
%>

    </div>


        <a href="profile.jsp?username=northy">visit northy</a>
<div id="text">

<form action="updateUserProfile.jsp" method="POST">

    <table id="text">
        <tr>
  <th> Your name:</th>
  <th>
            <%if(session.getAttribute("name")!=null)
                out.write("<input type=\"text\" name=\"name\" placeholder="+session.getAttribute("name")+"/>");
            else
                 out.write("<input type=\"text\" name=\"name\" placeholder=\"your New name\" />");
%>
        </th></tr>
        <tr>
            <th>Your surname:</th>
            <th>
              <%if(session.getAttribute("surname")!=null)
              out.write("<input type=\"text\" name=\"surname\" placeholder="+session.getAttribute("surname")+"/></br>");
        else
            out.write("<input type=\"text\" name=\"surname\" placeholder=\"your New surname\" /></br>");
    %>
            </th></tr>
        <tr>
            <th>Your Date Of Birth:</th>
            <th>
    <%if(session.getAttribute("dateOfBirth")!=null)
        out.write(" <input type=\"date\" name=\"dateOfBirth\" placeholder="+session.getAttribute("dateOfBirth")+ "></br>");
        else
            out.write(" <input type=\"date\" name=\"dateOfBirth\" placeholder=\"your birh date\" ></br>")
        ;%>
            </th></tr>
        <tr>
            <th>Your Interest List*:</th>
            <th>
            <%if(session.getAttribute("Interests")!=null)
        out.write(" <input type=\"text\" name=\"interests\" placeholder="+session.getAttribute("Interests")+"></br>");
        else
             out.write(" <input type=\"text\" name=\"interests\" placeholder=\"your interest\"></br>");

                          %>
            </th></tr>
        <tr>
            <th>Your Welcome Text:</th>
            <th>
             <%if(session.getAttribute("welcomeText")!=null)
        out.write(" <input type=\"text\" name=\"welcomeText\" placeholder="+session.getAttribute("welcomeText")+"></br>");
               else
                    out.write(" <input type=\"text\" name=\"welcomeText\" placeholder=\"a welcome Text\" ></br>");
        %>
            </th></tr>
        <tr><th></th><th><a href="deleteProfile.jsp">Delete My Account/Profile</a>
            <input type="submit" value="Submit" />
            </th></tr>
            </table>
</br>
</br>
</br>
</br>


</form>


        </div>


    </body>
</html>
